package com.utonw.carloan.fragment.applyloan;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sensetime.library.finance.ocr.card.IdCardInfo;
import com.utonw.carloan.R;
import com.utonw.carloan.fragment.BaseFragment;
import com.utonw.carloan.global.ReleaseData;
import com.utonw.carloan.utils.ViewUtils;

import java.util.HashMap;

/**
 * Created by SEELE on 2017/3/22.
 */

/**
 * 申请贷款流程9：提交确认
 */
public class LoanStepNineFragment extends BaseFragment {
    //最终展示的布局
    private LinearLayout mResultToShow;

    @Override
    public int setLayout() {
        return R.layout.fragment_applyloan_step_nine;
    }

    @Override
    public void initView(View view) {
        mResultToShow = (LinearLayout) mActivity.findViewById(R.id.ll_loan_result_to_show);
    }

    @Override
    public void initData() {
        /**
         * 本页数据仅做展示用，无实际业务逻辑
         */
        setAllText();
    }

    @Override
    protected void getIdcardFrontInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getIdcardBackInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getBankcardInfo(Intent cardData) {

    }

    @Override
    protected void getCreditcardInfo(Intent cardData) {

    }

    public void setAllText() {

        ReleaseData.getAllResultEntry.putAll(ReleaseData.getAllResultContent);
        mResultToShow.removeAllViews();
        for (Object o : ReleaseData.getAllResultEntry.keySet()) {
            String key1 = (String) o;
            //获取每个要显示的View map对象
            HashMap<Integer, View> mapToShow = ReleaseData.getAllResultEntry.get(key1);
            for (Object j : mapToShow.keySet()) {
                int key2 = (int) j;
                View viewToShow = mapToShow.get(key2);
                try {
                    EditText tempText = (EditText) viewToShow;
                    //生成布局
                    View view = ViewUtils.addItemView(R.layout.choosebar_final_just_show);
                    TextView tempTitle = (TextView) view.findViewById(R.id.tv_choosebar_name);
                    TextView tempContent = (TextView) view.findViewById(R.id.tv_choosebar_to_show);
                    tempTitle.setText(getString(key2));
                    tempContent.setText(tempText.getText());
                    //注入布局文件
                    mResultToShow.addView(view);

                } catch (Throwable e) {
                    TextView tempText = (TextView) viewToShow;
                    //生成布局
                    View view = ViewUtils.addItemView(R.layout.choosebar_final_just_show);
                    TextView tempTitle = (TextView) view.findViewById(R.id.tv_choosebar_name);
                    TextView tempContent = (TextView) view.findViewById(R.id.tv_choosebar_to_show);
                    tempTitle.setText(getString(key2));
                    tempContent.setText(tempText.getText());
                    //注入布局文件
                    mResultToShow.addView(view);

                }
            }

        }

    }

}
